﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>添加部门记录</title>
    <!--link to style-->
    <link rel="stylesheet" href="css/adapt.css" />
    <link rel="stylesheet" href="../css/bootstrap.min.css" />
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css" />
    <!--<link rel="stylesheet" href="css/adapt.css" />-->
    <!--//End link to style-->
    <script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>
    <div class="Body clearfix">
        <div class="catlog">
            <span class="cat_block">当前位置</span>
            <span class="cat_block icon-chevron-right">部门记录</span>
            <span class="cat_block icon-chevron-right">添加部门记录</span>
        </div>
        <div class="archt">
            <form method="post" action="">
                <div class="arc_line">
                    <span class="arc_tit">部门号：</span>
                    <input class="atc_input" id="dno" type="text" name="dNo" readonly="readonly" />
                </div>
                <div class="arc_line">
                    <span class="arc_tit">部门名：</span>
                    <input class="atc_input" id="dname" type="text" name="dName" />
                </div>
                <div class="arc_line">
                    <span class="arc_tit">备注：</span>
                    <input class="atc_input" id="dinfo" type="text" name="dDetil" />
                </div>
                <input class="submit" type="button" value="提交" />
            </form>
        </div>

    </div>



    <script>
        $(function () {

        	$.ajax({
                type: "Post",
                url: "/hr_doc/servlet/DepartServlet",
                data: {
               	 Command:"dno",
                },
                async: false,
                dataType: "json",
                success: function (d) {
					console.log(d);
	               	if(d.code == 1){
						$("#dno").val(d.result);
	               	}
                },
                error: function (xmlHttpRequest, textStatus, errorThrown) {
                	location.href = "/hr_doc/login.html"
                }
            });	
        	
        	
        	
        	$(".submit").click(function(){
        		
        		var dno = $("#dno").val();
        		var dname = $("#dname").val();
        		var dinfo = $("#dinfo").val();
        		
        		$.ajax({
                    type: "Post",
                    url: "/hr_doc/servlet/DepartServlet",
                    data: {
                   	 Command:"add",
                   	 dno:dno,
                   	 dname:dname,
                   	 dinfo:dinfo
                    },
                    async: false,
                    dataType: "json",
                    success: function (d) {
    					console.log(d);
    	               	if(d.code == 1){
    	               		alert(d.result)
    	               		location.href = "/hr_doc/subPage/departRecord.html";
    	               	}
                    },
                    error: function (xmlHttpRequest, textStatus, errorThrown) {
                    	location.href = "/hr_doc/login.html"
                    }
                });	
        		
        	});
        	
        	
        	
        })
    </script>
</body>
</html>